<template>
  <view class="user_oper_container">
    <view class="flex_row">
      <template v-for="(item, index) in rowDataList">
        <view class="mode_row" :key="index" v-if="item.isShow !== false" @click="item.callback">
          <view :class="item.icon" class="icon_font"></view>
          <view class="oper_text">{{ item.label }}</view>
        </view>
      </template>
    </view>
  </view>
</template>

<script setup lang="ts" name="userInfo">
  import { useNavigatePage } from '@/hooks/navigateTo'
  import useToastMsg from '@/hooks/sysMsg'
  import useUserInfoStore from '@/store/userInfo'
  import { LoginStatusCheck } from '@/utils/login'
  import { computed, ref } from 'vue'
  const toastMsg = useToastMsg()
  const navigatePage = useNavigatePage()
  const userInfoStore = useUserInfoStore()
  const userInfo = computed(() => userInfoStore.getUserInfo)
  const rowDataList = ref([
    {
      label: '订单',
      icon: 't-icon-wodedingdan2',
      callback: () => {
        LoginStatusCheck(async () => navigatePage.navigateTo('/pages/order/index'))
      },
    },
    {
      label: '余额',
      icon: 't-icon-zhifu-yue',
      callback: () => {
        LoginStatusCheck(async () => navigatePage.navigateTo('/pages/balance/index'))
      },
    },
    {
      label: '关于',
      icon: 't-icon-guanyu',
      callback: () => {
        // navigatePage.redirectTo("/pages/help/index");
      },
    },
    {
      label: '帮助',
      icon: 't-icon-bangzhuzhongxin',
      callback: () => {
        navigatePage.navigateTo('/pages/help/index')
      },
    },
    {
      label: '缓存',
      icon: 't-icon-henjiqingli',
      isShow: userInfo.value.phoneNumber == '15093343179',
      callback: () => {
        uni.setStorageSync('token', '')
        uni.setStorageSync('rtoken', '')
        userInfoStore.setUserInfo({ userId: '' })
        toastMsg.showToast('缓存清理成功')
      },
    },
  ])
</script>

<style scoped lang="scss">
  .user_oper_container {
    background: #ffffff;
    border-radius: 16rpx;
    padding: 20rpx;
  }
  .mode_row {
    text-align: center;
    width: 100%;
    .oper_text {
      font-size: 28rpx;
    }
  }
  .icon_font {
    margin: 0 auto;
    width: 62rpx;
    height: 62rpx;
  }
</style>
